<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>  
<%@ taglib prefix="njtc" uri="http://www.njtcedu.cn/app/core" %>

<div class="content" id="content" data-nav="nav_systemconfig">
	<h1>首页广告</h1>
	
    <div class="fullColForForm boutiqueBannerImg">
        <label for="bannerImage">广告图片1</label>
        <img src="${pageContext.request.contextPath}/${images[0].imageUrl}">
        <input type="file" class="imgUpload" name="imageFile" id="a"/>
    </div>
    
    <div class="imgColForForm boutiqueNormalImg">
        <label for="pageImage">广告图片2</label>
        <img  src="${pageContext.request.contextPath}/${images[1].imageUrl}">
        <input type="file" class="imgUpload" name="imageFile" id="b"/>
    </div>
    <br>
     <div class="imgColForForm boutiqueNormalImg">
        <label for="pageImage">广告图片3</label>
        <img src="${pageContext.request.contextPath}/${images[2].imageUrl}">
        <input type="file" class="imgUpload" name="imageFile" id="c"/>
    </div>
   <br>
     <div class="imgColForForm boutiqueNormalImg">
        <label for="pageImage">广告图片4</label>
        <img  src="${pageContext.request.contextPath}/${images[3].imageUrl}">
        <input type="file" class="imgUpload" name="imageFile" id="d"/>
    </div>
</div>
<script>
$("input:file").change(function(){
	var rootPtah = "${pageContext.request.contextPath}";
	var fileInputId = $(this).attr("id");
	var url = "${pageContext.request.contextPath}/intranet/adimage/" + fileInputId;
	var img = $(this).prev("img");
	$.ajaxFileUpload ({
	url : url,
	fileElementId :fileInputId,
	dataType : 'json',
	success : function (data, status){
		if (data) {
			img.attr("src", rootPtah + data.imageUrl);
		}
	},
	
	error: function (data, status, e){
		alert(e);
		}
	});
});
</script>